package ar.edu.unq.wannaplay.utils;

import java.io.Serializable;

/**
 * Tupla de numeros.
 */
public class Pair<F, S> implements Serializable {
    private static final long serialVersionUID = 1L;

    private F first;

    private S second;

    public Pair() {
        super();
    }

    public Pair(final F first, final S second) {
        super();
        this.first = first;
        this.second = second;
    }

    // setters && getters
    public void setFirst(final F first) {
        this.first = first;
    }

    public F getFirst() {
        return first;
    }

    public void setSecond(final S second) {
        this.second = second;
    }

    public S getSecond() {
        return second;
    }

    public static Pair<Integer, Integer> defaultPair() {
        return new Pair<Integer, Integer>(0, 0);
    }

    @Override
    public String toString() {
        return "(" + first.toString() + ", " + second.toString() + ")";
    }

    @Override
    public int hashCode() {
        int prime = 31;
        int result = 1;
        result = prime * result + (first == null ? 0 : first.hashCode());
        result = prime * result + (second == null ? 0 : second.hashCode());
        return result;
    }

    @SuppressWarnings("rawtypes")
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        } else {
            return first.equals(((Pair) obj).getFirst()) && second.equals(((Pair) obj).getSecond());
        }
    }

}
